package com.darren.framework.Exception;

import com.darren.framework.Bean.ResponseBean;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import javax.servlet.http.HttpServletRequest;

@RestControllerAdvice
public class GlobalControllerAdvice {


    protected Logger logger = LogManager.getLogger(getClass());

    /**
     * 业务异常
     */
    @ExceptionHandler(ArchiveException.class)
    public ResponseBean archiveException(HttpServletRequest request, ArchiveException e) {
        logger.error(e.getMessage(), e);
        return ResponseBean.isError(e.getMessage());

    }


}
